<template>
	<view class="mine_content">
		<mineUserInfo :userData="userData"></mineUserInfo>
		<view class="task_content" @tap="clickToTask">
			<image class="" :src="task_url"  mode="widthFix"></image>
		</view>
		<mineFunction :dataList="mineFunctionList" @clickToCollect="clickToCollect"/>
		<mineAddCollect v-show="isShowCollect" @click="clickToAddCollect"/>
	</view>
</template>

<script>
	import customNav from '../../../components/custom-navbar/custom-navbar.vue'
	import mineUserInfo from '../../tabBar/mine/mineUserInfo.vue'
	import mineFunction from '../../tabBar/mine/mineFunction.vue'
	import mineAddCollect from '../../tabBar/mine/mineAddCollect.vue'
	
	import interfaces from '@/utils/interfaces.js'
	import config from '@/utils/config.js'
    import images from '@/utils/images'
	import tools from '@/utils/tools.js'
	import {
		mapState
	} from 'vuex';
	export default {
		components: {
			customNav,
			mineUserInfo,
			mineFunction,
			mineAddCollect
		},
		data() {
			return {
				task_url: images.mine_task,
				userData: {},
				taskData: {},
				mineFunctionList:[],
				isShowCollect: false
			}
		},
		computed: {
			...mapState({
				userInfo: state => state.user.userInfo,
				statusBarHeight: state => state.layout.statusBarHeight,
				windowWidth: state => state.layout.windowWidth,
				windowHeight: state => state.layout.windowHeight,
				platform: state => state.layout.platform
			})
		},
		onLoad() {
			this.initData()
		},
		onShow(){
			this.userData = tools.get_user_info();
			this.initMineListData();
		},
		methods:{
			initData(){
				let self = this;
				tools.get_user_info_by_serve(self,()=>{
					self.userData = tools.get_user_info()
				})
			},
			initMineListData() {
				let self = this;
				self.request({
					url: interfaces.mine_listData,
					method:"GET",
					success:(res)=> {
						console.log("获取我的数据", res)
						self.taskData = res.content.banner_list[0];
						let icons_list = res.content.icons_list;
						// #ifdef MP-WEIXIN
						if(this.platform=='ios'&&(this.userInfo.ios_payment!=1)){
							for (var i = 0; i < icons_list.length; i++) {
								if(icons_list[i].name == '充值记录'){
									icons_list[i].noShow = true;
								}
							}
						}
						// #endif
						self.mineFunctionList = icons_list;
					}
				})
			},
			clickToTask() {
				tools.navigateToWelfare()
			},
			clickToCollect() {
				this.isShowCollect = true
			},
			clickToAddCollect() {
				this.isShowCollect = false
			}
		}
	}
</script>

<style lang="scss" scoped>
	.mine_content {
		display: flex;
		box-sizing: border-box;
		flex-direction: column;
		
		.task_content{
			display: flex;
			box-sizing: border-box;
			justify-content: center;
			align-items: center;
			overflow: hidden;
			margin: 20px;
			image{
				width: 690rpx;
				height: 172rpx;
			}
		}
	}

</style>